<?php

declare(strict_types=1);

namespace app\api\controller\v1;
use app\common\Frontend;
use app\common\model\PublicStatus;
use app\common\model\Question as ModelQuestion;
use app\common\model\QuestionType;

class Question extends Frontend
{

    protected array $noNeedLogin = ['askedQuestion','questionClass'];

    protected $model;
    public function initialize(): void
    {
        parent::initialize();
        $this->model = new ModelQuestion();
    }

   

    //常见问题
    public function askedQuestion(){
        $q_type = $this->request->param('q_type',0);
        $where[] = ['q_type', '=', $q_type];
        $where[] = ['status', '=', PublicStatus::PUBLIC_STATUS_ONE];
        $res = ModelQuestion::where($where)->select();
        $this->success('', $res);
    }


     //问题类型
     public function questionClass(){
        $res = QuestionType::with(['question'])->where(['status'=>PublicStatus::PUBLIC_STATUS_ONE])->select();
        $this->success('', $res);
    }
}